﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace DatabaseCore
{
    public class RoleToOrderStatusDao : IRoleToOrderStatusDao
    {
        public List<int> GetOrderStatusByRole(int roleId)
        {
            using (var ctx = new ExportDBEntities())
            {
                var entities = from x in ctx.tbl_RoleToOrderStatus
                               where x.RoleId == roleId
                               select x.OrderStatusId;

                if (entities == null)
                    return new List<int>() { 0 };

                return entities.ToList();
            }
        }

        public List<tbl_OrderStatus> GetStatusByRole(int roleId)
        {
            using (var ctx = new ExportDBEntities())
            {
                var entities = from x in ctx.tbl_RoleToOrderStatus
                               join o in ctx.tbl_OrderStatus on x.OrderStatusId equals o.Id
                               where x.RoleId == roleId
                               select o;

                return entities.ToList();
            }
        }
    }
}
